CXX := gcc
CXXFLAGS := -Wall -g
EXE := ftp_client ftp_server
OBJDIR := obj
SRCDIR := src

all: ftp_client ftp_server
flush: clean all 

srcClient := $(patsubst %.c, $(SRCDIR)/%.c, ftp_client.c client_shell.c  network.c  error.c filesys.c)
srcServer :=  $(patsubst %.c, $(SRCDIR)/%.c, ftp_server.c  server_backend.c  network.c  error.c filesys.c)

objClient := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(srcClient))
objServer := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(srcServer))

.PHONY: all clean

ftp_client: $(objClient)
	$(CXX) $(CXXFLAGS) $^ -o $@
ftp_server: $(objServer)
	$(CXX) $(CXXFLAGS) $^ -o $@

$(OBJDIR)/%.o : $(SRCDIR)/%.c 
	$(CXX) $(CXXFLAGS) -c $< -o $@


clean:
	rm -rf $(EXE)  
	rm -rf $(OBJDIR)/*.o 


